import 'package:flutter/material.dart';
import 'package:flutter_neumorphic_plus/flutter_neumorphic.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:psi/theme/app_colors.dart';
import 'package:psi/utils/widget_util.dart';
import 'package:psi/widgets/gesture.dart';
import 'package:psi/widgets/text_widget.dart';

import '../../generated/assets.dart';
import 'login_logic.dart';

class LoginPage extends StatelessWidget {
  final logic = Get.find<LoginLogic>();
  final state = Get.find<LoginLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 40.w),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              (ScreenUtil().screenHeight / 5).verticalSpace,
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  TextWidget(
                    "登录",
                    fontSize: 32.sp,
                    color: Color(0xFF242F44),
                    fontWeight: FontWeight.w500,
                  ),
                  Spacer(),
                  TextWidget(
                    "没有账号？",
                    color: Color(0xFFA6A6A6),
                  ),
                  ClickWidget(
                      onTap: logic.goToRegister,
                      child: TextWidget(
                        "立即注册",
                        color: primaryColor.withOpacity(0.8),
                      ))
                ],
              ),
              32.verticalSpace,
              WidgetUtil.inputWidget(
                height: 40.sp,
                  placeHolder: "请输入用户名/手机号",
                  onChanged: (value) {
                    state.req.value.account = value;
                  }),
              20.verticalSpace,
              WidgetUtil.inputWidget(
                  height: 40.sp,
                  obscureText: true,
                  showReal: true,
                  placeHolder: "请输入密码",
                  onChanged: (value) {
                    state.req.value.password = value;
                  }),
              64.verticalSpace,
              WidgetUtil.getCardItem(
                  onTap: logic.loginAction,
                  padding: EdgeInsets.zero,
                  color: primaryColor.withOpacity(0.8),
                  child: Container(
                      height: 48.w,
                      alignment: Alignment.center,
                      child: TextWidget(
                        "登录",
                        color: Colors.white,
                        fontSize: 18.sp,
                        fontWeight: FontWeight.bold,
                      ))),
              16.verticalSpace,
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Obx(() {
                    return WidgetUtil.imageBtn(
                        imageName: state.read.value ? R.check : R.uncheck,
                        size: 14,
                        onTap: () {
                          state.read.value = !state.read.value;
                        });
                  }),
                  8.horizontalSpace,
                  TextWidget(
                    "我已阅读并同意",
                    fontSize: 14,
                    color: Color(0xFF999999),
                  ),
                  TextWidget(
                    " 用户协议 ",
                    fontSize: 14,
                    color: primaryColor.withOpacity(0.8),
                  ),
                  TextWidget(
                    "和",
                    fontSize: 14,
                    color: Color(0xFF999999),
                  ),
                  TextWidget(
                    " 隐私政策",
                    fontSize: 14,
                    color: primaryColor.withOpacity(0.8),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
